from pymilvus import connections, Collection, FieldSchema, DataType, CollectionSchema
import random
from pprint import pprint

connections.connect(
    "default", host="192.168.1.62", port="19530", db_name="zhangrenyang"
)

collection = Collection("mixed_collection")
query_vector = [random.random() for _ in range(128)]
search_params = {"metric_type": "COSINE", "params": {"nprobe": 10}}
results = collection.search(
    # 查询向量的数据
    data=[query_vector],
    # 指定搜索向量的字段
    anns_field="embedding",
    #  搜索参数配置
    param=search_params,
    limit=5,
    # 指定过滤的条件
    expr="category in [2]",
)
print(results)
